<?php
header('Content-Type: application/json');


$servername = "localhost";
$username = "root";
$password = "root";
$dbname = "emp";

// 创建连接
$conn = new mysqli($servername, $username, $password, $dbname);

// 检查连接
if ($conn->connect_error) {
    die("连接失败: " . $conn->connect_error);
}

// 查询数据
$sql = "SELECT date, salary FROM salary ORDER BY date ASC";
$result = $conn->query($sql);

$data = array();
if ($result->num_rows > 0) {
    while($row = $result->fetch_assoc()) {
        $timestamp = strtotime($row["date"]);
        $data[] = array($timestamp * 1000, $row["salary"]);
    }
}

$conn->close();

// 返回JSON数据
echo json_encode(array('data' => $data));
?>